<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>注册</title>
    <!-- <link rel="stylesheet" type="text/css" href="../css/api.css" /> -->
    <style>
        /*注册*/

        * {
            margin: 0;
            padding: 0;
        }

        a {
            text-decoration: none;
        }

        a:hover {
            text-decoration: none;
        }

        ul,
        li {
            list-style-type: none;
        }

        html,
        body {
            width: 100%;
            height: 100%;
            font-family: Arial;
            background-color: #fcfcfc;
            font-size: 18px
        }

        *,
        *:after,
        *:before {
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
        }

        .pcc-loginCase {
            width: 100%;
            height: 100%
        }

        .pcc-loginCase .pcc-logoCase {
            width: 100%;
            height: auto;
            text-align: center;
            background-color: #ff5555;
            padding: 5rem 0;
        }

        .pcc-loginCase .pcc-logoCase img {
            width: 26%;
        }

        .pcc-loginCase .pcc-formCase {
            width: 90%;
            height: auto;
            ;
            background-color: #ffffff;
            border-radius: 5px;
            position: absolute;
            left: 5%;
            top: 11rem;
            box-shadow: #e7e7e7 0 3px 5px 0;
            padding: 1rem;
        }

        .pcc-loginCase .pcc-formCase .pcc-item {
            width: 100%;
            height: 2.5rem;
            background-color: #f8f8f8;
            border-radius: 5px;
            margin-top: 0.5rem;
            display: flex;
        }

        .pcc-loginCase .pcc-formCase .pcc-item label {
            width: 15%;
            height: 2.5rem;
            line-height: 2.5rem;
            font-size: 0.7rem;
            text-indent: 0.5rem;
            color: #666666;
        }

        .pcc-loginCase .pcc-formCase .pcc-item input {
            width: 85%;
            height: 2.5rem;
            border: 0;
            background: none;
            outline: none;
            font-size: 0.7rem;
            color: #666666;
        }

        .pcc-nameL {
            background: url("../image/Personal1.png")no-repeat;
            background-size: 0.8rem;
            background-position: 0.5rem center;
        }

        .pcc-passwordL {
            background: url("../image/passwordicon.png")no-repeat;
            background-size: 0.8rem;
            background-position: 0.5rem center;
        }

        .pcc-codeL {
            background: url("../image/code.png")no-repeat;
            background-size: 1rem;
            background-position: 0.45rem center;
        }

        .pcc-loginCase .pcc-bntCase {
            width: 100%;
            text-align: center;
            padding-bottom: 0.8rem;
            margin-top: 6rem
        }

        .pcc-loginCase .pcc-bntCase button {
            width: 60%;
            height: 3rem;
            color: #ffffff;
            border: 0;
            font-size: 18px;
            background-color: #fe6263;
            border-radius: 3px;
            box-shadow: #e7e7e7 0 3px 5px 0;
        }

        .pcc-loginCase .pcc-bntCase p {
            width: 100%;
            font-size: 12px;
            color: #b5b5b5;
            margin-top: 4rem;
        }

        .pcc-tishi {
            width: 100%;
            line-height: 35px;
            text-align: center;
            position: fixed;
            top: 50%;
            display: none;
        }

        .pcc-tishi span {
            line-height: 35px;
            background: rgba(0, 0, 0, .6);
            text-align: center;
            color: #ffffff;
            font-size: 14px;
            padding: 7px;
            border-radius: 5px;
        }

        .pcc_tancon {
            display: block;
        }

        .pcc_registered {
            width: 100%;
            padding: 1rem 1rem 3rem 1rem;
            text-align: right;
        }

        .pcc_registered a {
            color: #fe6263;
            font-size: 14px;
        }

        .pcc-code {
            width: 50%
        }

        .pcc-codeBnt {
            width: 35%;
            height: 1.5rem;
            font-size: 0.7rem;
            color: #aaaaaa;
            border-top: 0;
            border-bottom: 0;
            border-right: 0;
            border-left: 1px solid #dddddd;
            background: none;
            /*margin-top: 0.5rem;*/
        }
    </style>
</head>

<body>
    <div class="pcc-loginCase">
        <div class="pcc-logoCase">
            <img src="../image/logo-img.png" alt="" />
        </div>
        <div class="pcc-formCase">
            <div class="pcc-item">
                <label class="pcc-nameL"></label>
                <input class="pcc-name" type="number" id='pcc_us_number' placeholder="手机号码" maxlength="16" />
            </div>
            <div class="pcc-item">
                <label class="pcc-passwordL"></label>
                <input class="pcc-password" type="password" id='pcc_us_password' placeholder="密码" maxlength="18" />
            </div>
            <div class="pcc-item">
                <label class="pcc-codeL"></label>
                <input class="pcc-code" type="number" id='login_code_input' placeholder="验证码" maxlength="18" style="width:50%" />
                <input type="button" class="pcc-codeBnt" id="get_reg_code" value="获取验证码" />
                <!-- <button class="pcc-codeBnt" id="get_reg_code">获取验证码</button> -->
            </div>
        </div>
        <div class="pcc-bntCase">
            <div class="pcc_registered"><a href="#" onclick="openpage('login');">已有账号</a></div>
            <button class="pcc-login" onclick="minwinBtn();">注&nbsp;册</button>
            <p>启安云 V1.0</p>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/APICloud-rest.js"></script>
<script type="text/javascript" src="../script/SHA1.js"></script>
<script type="text/javascript">
    apiready = function() {

    };
    // 点击登录
    function minwinBtn() {
        var pcc_us_number = $api.dom('#pcc_us_number');
        var pcc_us_password = $api.dom('#pcc_us_password');
        var login_code_input = $api.dom('#login_code_input');
        var pcc_us_numberValue = pcc_us_number.value;
        var pcc_us_passwordValue = pcc_us_password.value;
        var login_code_inputValue = login_code_input.value;
        if (pcc_us_numberValue == "" || !/^[1]([3][0-9]{1}|[5][0-9]{1}|[7][0-9]{1}|[8][0-9]{1})[0-9]{8}$/.test(pcc_us_numberValue)) { //验证手机号
            api.alert({
                title: '提示',
                msg: '手机号码错误！',
            }, function(ret, err) {

            });
            return false;
        }
        if (pcc_us_passwordValue == "" || !/[A-Za-z0-9]{8,16}$/.test(pcc_us_passwordValue)) {
            api.alert({
                title: '提示',
                msg: '请输入8-16位长度的正确密码！',
            }, function(ret, err) {

            });
            return false;
        }
        if (login_code_inputValue == "") { //验证密码
            api.alert({
                title: '提示',
                msg: '请输入验证码！',
            }, function(ret, err) {

            });
            return false;
        }
        var client = new Resource("A6081574015393", "F2EDB6AF-B6F9-488D-074B-A40489B4477B");
        var User = client.Factory("user");
        User.save({
            "username": pcc_us_numberValue,
            "password": pcc_us_passwordValue
        }, function(ret, err) {
            api.alert({
                title: '提示',
                msg: '注册成功',
            }, function(ret, err) {
                if (ret) {
                    var jsfun = 'funsetusnumber(\"' + pcc_us_numberValue + '\");';
                    api.execScript({
                        name: 'login',
                        script: jsfun
                    });
                    api.openWin({
                        name: 'login',
                        url: './login.html',
                    });

                } else {

                }
            });
        })


    };

    function openpage(url) {
        api.openWin({
            name: url,
            url: './' + url + '.html',
            pageParam: {
                name: 'test'
            }
        });
    };

    var wait = 60;

    function time(o) {
        if (wait == 0) {
            o.removeAttribute("disabled");
            o.value = "获取验证码";
            wait = 60;
        } else {
            o.setAttribute("disabled", true);
            o.value = "重新发送(" + wait + ")S";
            wait--;
            setTimeout(function() {
                    time(o)
                },
                1000)
        }
    }
    document.getElementById("get_reg_code").onclick = function() {
        time(this);
    };
</script>

</html>
